<template>
	<div>
		<el-dialog
		        :title="addTitle"
				@close="$emit('confirm')"
				:close-on-click-modal="false"
		        :visible.sync="formShow"
		        width="1000px"
		>
		  <div>
			  <el-form ref="form" label-width="80px">
				  <el-form-item label="品牌名称">
				  		<el-input v-model="form.brand_name" size="small"></el-input>
				  </el-form-item>
				  <el-form-item label="品牌排序">
				  		<el-input v-model="form.sort" type="number" 
							size="small"></el-input>
				  </el-form-item>
				  <el-form-item label="品牌图片">
				  		<el-button size="mini" @click="isShow=true" type="primary">选择图片</el-button>
				  </el-form-item>
				  <el-form-item v-if="form.img_url">
					  <div style="display: flex;">
						  <div style="position: relative;margin-right: 10px;">
							  <img style="width: 100px;height: 100px;" :src="form.img_url" alt="">
							  <i @click="delImg(i)" class="el-icon-circle-close" style="font-size: 20px;position: absolute;top: 0;right:0;cursor: pointer;"></i>
						  </div>
					  </div>
				  </el-form-item>
				  <el-form-item >
				      <el-button type="primary" @click="confirm" size="small">确定</el-button>
				  </el-form-item>
			  </el-form>
		  </div>
		</el-dialog>
		<el-dialog title="选择图片"
				:close-on-click-modal="false"
				:modal-append-to-body="false"
				:append-to-body="true"
		        :visible.sync="isShow"
		        width="1050px">
			 <div style="padding-bottom: 30px;">
				 <imgSys @getImgData="getImgData" />
			 </div>
		     
		</el-dialog>
	</div>
</template>

<script>
	import imgSys from '@/components/imgSys'
	export default {
		components:{
			imgSys
		},
		data() {
			return {
				title:"",
				form:{
					id:null,
					img_url:'',
					is_default:"0",
					brand_name:'',
					old_brand:'',
					sort:1
				},
				addTitle:'新增',
				isShow:false,
				table_name:'hs_brand',
				formShow:true
			}
		},
		methods:{
			getImgData(val){
				this.form.img_url = val
				this.isShow = false
			},
			confirm(){
				let url
				if(this.form.id){
					url = '/prodectSys/editBanner'
				}else{
					url = '/prodectSys/addBrand'
				}
				this.$post(url,this.form,res=>{
					if(res.data.code==200){
						this.$message.success('操作成功')
						this.formShow = false
						this.$emit('confirm')
					}
				})
			},
		}
	}
</script>

<style>
</style>